using HKB.Common;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
namespace HKB.Web
{
	public class UserBll
	{
		private Conn conn;
		private Pagination _p;
		protected Pagination m_p
		{
			get
			{
				Pagination p;
				if (this._p == null)
				{
					this._p = new Pagination();
					this._p.SQL_LeftJoinTable = "HL_Group";
					this._p.SQL_LeftJoinField = "GroupName";
					this._p.SQL_JoinField = "GroupID";
					this._p.SQL_JoinField2 = "GroupID";
					this._p.P_Object = "位会员";
					p = this._p;
				}
				else
				{
					p = this._p;
				}
				return p;
			}
		}
		public UserBll()
		{
			this.conn = Text.GetComponent<Conn>("conn", HttpContext.Current.CurrentHandler);
		}
		public UserBll(Conn _conn)
		{
			this.conn = _conn;
		}
		public DataTable GetAllUsers()
		{
			return this.conn.GetDataTable("SELECT HL_User.*,HL_Group.GroupName FROM [HL_User] Left Join [HL_Group] on HL_User.GroupID = HL_Group.GroupID ORDER BY HL_User.UserID DESC");
		}
		public DataTable GetUserNameID()
		{
			return this.conn.GetDataTable("SELECT UserID,UserName FROM [HL_User] ORDER BY UserID DESC");
		}
		public DataTable GetAllUsersOnPage(int m_page, string wherestr, string orderbystr, int pagesize)
		{
			if (orderbystr == "")
			{
				orderbystr = "UserID Desc";
			}
			return this.m_p.GetDataTable("HL_User", m_page, pagesize, "UserID", wherestr, orderbystr, this.conn, null);
		}
		public string ShowPagePanel(string pageHead)
		{
			string result;
			if (this.m_p != null)
			{
				this.m_p.P_LinkHead = pageHead;
				string text = this.m_p.ShowPagePanel();
				result = text;
			}
			else
			{
				result = "";
			}
			return result;
		}
		public string ShowPagePanelJs()
		{
			string result;
			if (this.m_p != null)
			{
				result = this.m_p.ShowPagePanelJs();
			}
			else
			{
				result = "";
			}
			return result;
		}
		public string ShowPagePanel(string pageHead, bool isShowDownList)
		{
			string result;
			if (this.m_p != null)
			{
				this.m_p.P_isShowDownList = isShowDownList;
				this.m_p.P_LinkHead = pageHead;
				string text = this.m_p.ShowPagePanel();
				result = text;
			}
			else
			{
				result = "";
			}
			return result;
		}
		public string ShowPagePanelJs(bool isShowDownList)
		{
			string result;
			if (this.m_p != null)
			{
				this.m_p.P_isShowDownList = isShowDownList;
				string text = this.m_p.ShowPagePanelJs();
				result = text;
			}
			else
			{
				result = "";
			}
			return result;
		}
		public int GetUserIDByUserName(string UserName)
		{
			int result = 0;
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@UserName", DbType.String, UserName);
			object scalar = this.conn.GetScalar("Select UserID From [HL_User] Where ([UserName] = @UserName)", new IDbDataParameter[]
			{
				dbDataParameter
			});
			if (scalar != null)
			{
				result = Convert.ToInt32(scalar);
			}
			return result;
		}
		public DataTable GetUserByUserName(string UserName)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@UserName", DbType.String, UserName);
			return this.conn.GetDataTable("SELECT HL_User.*,HL_Group.GroupName FROM [HL_User] Left Join [HL_Group] on HL_User.GroupID=HL_Group.GroupID Where (HL_User.[UserName] = @UserName)", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public DataTable GetUserNameIDByUserName(string UserName)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@UserName", DbType.String, UserName);
			return this.conn.GetDataTable("SELECT UserID,UserName FROM [HL_User] Where (HL_User.[UserName] = @UserName)", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public DataTable GetUserLikeUserName(string UserName, int m_page, int pagesize)
		{
			DataTable result;
			if (UserName != null)
			{
				IDbDataParameter[] param = new IDbDataParameter[]
				{
					this.conn.CreateParameter("@UserName", DbType.String, UserName)
				};
				result = this.m_p.GetDataTable("HL_User", m_page, pagesize, "UserID", "Where (HL_User.UserName LIKE '%' + @UserName + '%')", "UserID Desc", this.conn, param);
			}
			else
			{
				result = null;
			}
			return result;
		}
		public DataTable GetUserLikeUserName(string UserName)
		{
			DataTable result;
			if (UserName != null)
			{
				IDbDataParameter[] parameters = new IDbDataParameter[]
				{
					this.conn.CreateParameter("@UserName", DbType.String, UserName)
				};
				result = this.conn.GetDataTable("SELECT UserID,UserName FROM [HL_User] Where (HL_User.UserName LIKE '%' + @UserName + '%')", parameters);
			}
			else
			{
				result = null;
			}
			return result;
		}
		public bool UpdateUserSex(int UserID, int Sex)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@Sex", DbType.Int32, Sex),
				this.conn.CreateParameter("@UserID", DbType.Int32, UserID)
			};
			return this.conn.Execute("UPDATE [HL_User] Set [Sex] = @Sex Where ([UserID] = @UserID)", parameters) > 0;
		}
		public bool UpdateUserScope(int UserID, decimal ballance, int ep)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@Balance", DbType.Decimal, ballance),
				this.conn.CreateParameter("@UserEP", DbType.Int32, ep),
				this.conn.CreateParameter("@UserID", DbType.Int32, UserID)
			};
			return this.conn.Execute("UPDATE [HL_User] Set [Balance] = @Balance ,[UserEP]=@UserEP Where ([UserID] = @UserID)", parameters) > 0;
		}
		public DataTable SearchUser(string QuickSearchValue, int page_index, int pagesize)
		{
			DateTime dateTime = DateTime.Now.Date.AddDays(1.0);
			DateTime dateTime2 = DateTime.Now.Date.AddDays(-1.0);
			DataTable allUsersOnPage;
			if (QuickSearchValue != null)
			{
				if (QuickSearchValue == "24hourlogin")
				{
					allUsersOnPage = this.GetAllUsersOnPage(page_index, "Where datediff(hh,LastLoginTime,getdate())<=24", "", pagesize);
					return allUsersOnPage;
				}
				if (QuickSearchValue == "24hourreg")
				{
					allUsersOnPage = this.GetAllUsersOnPage(page_index, "Where datediff(hh,RegTime,getdate())<=24", "", pagesize);
					return allUsersOnPage;
				}
				if (QuickSearchValue == "loginmost")
				{
					allUsersOnPage = this.GetAllUsersOnPage(page_index, "", "LoginTimes Desc,HL_User.UserID Desc", pagesize);
					return allUsersOnPage;
				}
				if (QuickSearchValue == "coinzero")
				{
					allUsersOnPage = this.GetAllUsersOnPage(page_index, "Where GoldCoin=0", "", pagesize);
					return allUsersOnPage;
				}
			}
			allUsersOnPage = this.GetAllUsersOnPage(page_index, "", "", pagesize);
			return allUsersOnPage;
		}
		public DataTable GetUserByUserID(int UserID)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@UserID", DbType.Int32, UserID);
			return this.conn.GetDataTable("Select * From [HL_User] Where ([UserID] = @UserID)", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public string GetUserNameByID(int id)
		{
			return (string)this.conn.GetScalar("Select UserName From [HL_User] Where UserID=" + id, new IDbDataParameter[0]);
		}
		public bool Delete(int UserID)
		{
			SqlParameter sqlParameter = new SqlParameter("@UserID", DbType.Int32);
			sqlParameter.Value = UserID;
			DataTable dataTable = this.conn.GetDataTable("pr_DeleteUser", new SqlParameter[]
			{
				sqlParameter
			});
			return dataTable.Rows.Count > 0 && dataTable.Rows[0][0].ToString().Trim() == "-1";
		}
		public bool UpdatePassport(int UserID, string NewPassword, string NewEmail, string NewQuestion, string NewAnswer)
		{
			DataTable userByUserID = this.GetUserByUserID(UserID);
			bool result;
			if (userByUserID.Rows.Count > 0)
			{
				DataRow dataRow = userByUserID.Rows[0];
				if (string.IsNullOrEmpty(NewPassword))
				{
					NewPassword = dataRow["Password"].ToString();
				}
				if (string.IsNullOrEmpty(NewEmail))
				{
					NewEmail = dataRow["Email"].ToString();
				}
				if (string.IsNullOrEmpty(NewQuestion))
				{
					NewQuestion = dataRow["Question"].ToString();
				}
				if (string.IsNullOrEmpty(NewAnswer))
				{
					NewAnswer = dataRow["Answer"].ToString();
				}
				IDbDataParameter[] parameters = new IDbDataParameter[]
				{
					this.conn.CreateParameter("@Password", DbType.String, NewPassword),
					this.conn.CreateParameter("@Email", DbType.String, NewEmail),
					this.conn.CreateParameter("@Question", DbType.String, NewQuestion),
					this.conn.CreateParameter("@Answer", DbType.String, NewAnswer),
					this.conn.CreateParameter("@UserID", DbType.Int32, UserID)
				};
				int num = this.conn.Execute("UPDATE [HL_User] Set [Password] = @Password, [Email] = @Email, [Question] = @Question, [Answer] = @Answer Where ([UserID] = @UserID)", parameters);
				result = (num == 1);
			}
			else
			{
				result = false;
			}
			return result;
		}
		public bool CheckUserExist(string CheckName, string CheckValue)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@CheckValue", DbType.String, CheckValue)
			};
			int num = this.conn.ExecuteCount("Select count(UserID) From [HL_User] Where ([" + CheckName + "] = @CheckValue)", parameters);
			return num > 0;
		}
		public bool AdminUser(string UserIdArray, string Type)
		{
			SqlParameter[] array = new SqlParameter[2];
			array[0] = new SqlParameter("@UserIDArray", DbType.String);
			array[0].Value = UserIdArray;
			array[1] = new SqlParameter("@Type", DbType.String);
			array[1].Value = Type;
			int num = this.conn.Execute("PR_AdminUser", array);
			return num > 0;
		}
		public bool AddUser(int UserID, string UserName, string Password, string Email, string Question, string Answer, int Sex, int GroupID, int UserEP, int IsLocked, decimal Balance, string RegIP)
		{
			if (string.IsNullOrEmpty(RegIP))
			{
				RegIP = "127.0.0.1";
			}
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@UserName", DbType.String, UserName),
				this.conn.CreateParameter("@Password", DbType.String, Password),
				this.conn.CreateParameter("@Email", DbType.String, Email),
				this.conn.CreateParameter("@Question", DbType.String, Question),
				this.conn.CreateParameter("@Answer", DbType.String, Answer),
				this.conn.CreateParameter("@Sex", DbType.Int32, Sex),
				this.conn.CreateParameter("@GroupID", DbType.Int32, GroupID),
				this.conn.CreateParameter("@UserEP", DbType.Int32, UserEP),
				this.conn.CreateParameter("@IsLocked", DbType.Int32, IsLocked),
				this.conn.CreateParameter("@Balance", DbType.Decimal, Balance),
				this.conn.CreateParameter("@RegIP", DbType.String, RegIP)
			};
			string text = "INSERT INTO [HL_User] (";
			text += "[UserName], [Password], [Email], [Question], [Answer], [Sex], [GroupID], [UserEP],  [IsLocked], [Balance], [RegIP], [RegTime]";
			text += ") VALUES (";
			object obj = text;
			text = string.Concat(new object[]
			{
				obj,
				"@UserName, @Password, @Email, @Question, @Answer, @Sex, @GroupID, @UserEP, @IsLocked, @Balance, @RegIP, '",
				DateTime.Now,
				"'"
			});
			text += ")";
			int num = this.conn.Execute(text, parameters);
			return num == 1;
		}
		public bool AddUser(string SerialNumber, int UserID, string UserName, string Password, string Email, string Question, string Answer, int Sex, int GroupID, int UserEP, int IsLocked, int Point, string RegIP, string fields, string fields_infr, IDbDataParameter[] myparam, params IDbDataParameter[] myparam_infr)
		{
			if (string.IsNullOrEmpty(RegIP))
			{
				RegIP = "127.0.0.1";
			}
			int num = 0;
			string str = "";
			if (myparam != null && fields != string.Empty)
			{
				str = "," + fields.Replace("@", "");
				fields = "," + fields;
				num = myparam.Length;
			}
			IDbDataParameter[] array = new IDbDataParameter[13 + num];
			array[0] = this.conn.CreateParameter("@UserName", DbType.String, UserName);
			array[1] = this.conn.CreateParameter("@Password", DbType.String, Password);
			array[2] = this.conn.CreateParameter("@Email", DbType.String, Email);
			array[3] = this.conn.CreateParameter("@Question", DbType.String, Question);
			array[4] = this.conn.CreateParameter("@Answer", DbType.String, Answer);
			array[5] = this.conn.CreateParameter("@Sex", DbType.Int32, Sex);
			array[6] = this.conn.CreateParameter("@GroupID", DbType.Int32, GroupID);
			array[7] = this.conn.CreateParameter("@UserEP", DbType.Int32, UserEP);
			array[8] = this.conn.CreateParameter("@IsLocked", DbType.Int32, IsLocked);
			array[9] = this.conn.CreateParameter("@Point", DbType.Int32, Point);
			array[10] = this.conn.CreateParameter("@RegIP", DbType.String, RegIP);
			array[11] = this.conn.CreateParameter("@UserID", DbType.Int32, UserID);
			array[12] = this.conn.CreateParameter("@SerialNumber", DbType.String, SerialNumber);
			for (int i = 13; i < num + 13; i++)
			{
				array[i] = myparam[i - 13];
			}
			bool flag = false;
			string text = "";
			if (myparam_infr != null && fields_infr != string.Empty)
			{
				text = "," + fields_infr.Replace("@", "");
				fields_infr = "," + fields_infr;
				flag = true;
			}
			string text2 = "INSERT INTO [HL_User] (";
			text2 = text2 + "[SerialNumber],[UserID],[UserName], [Password], [Email], [Question], [Answer], [Sex], [GroupID], [UserEP],  [IsLocked], [Point], [RegIP], [RegTime]" + str;
			text2 += ") VALUES (";
			object obj = text2;
			text2 = string.Concat(new object[]
			{
				obj,
				"@SerialNumber,@UserID,@UserName, @Password, @Email, @Question, @Answer, @Sex, @GroupID, @UserEP, @IsLocked, @Point, @RegIP, '",
				DateTime.Now,
				"'",
				fields
			});
			text2 += ")";
			this.conn.BeginTransaction();
			bool result;
			try
			{
				this.conn.ExecuteTransaction(text2, array);
				if (flag)
				{
					int num2 = (int)this.conn.ExecuteTransactionScalar("Select Top 1 UserID from [HL_User] Order By UserID Desc");
					string text3 = string.Concat(new object[]
					{
						"INSERT INTO [HL_UserInfo] (UserID",
						text,
						",CreateTime) values(",
						num2,
						fields_infr,
						",'",
						DateTime.Now,
						"')"
					});
					this.conn.ExecuteTransaction(text2, myparam_infr);
				}
			}
			catch
			{
				this.conn.Rollback();
				result = false;
				return result;
			}
			this.conn.Commit();
			result = true;
			return result;
		}
		public bool UpdateUser(int userid, string fields, string fields_infr, IDbDataParameter[] myparam, IDbDataParameter[] myparam_infr)
		{
			bool flag = false;
			bool flag2 = false;
			string commandText = string.Concat(new object[]
			{
				"Update [HL_User] Set ",
				fields,
				" Where UserID=",
				userid
			});
			string commandText2 = string.Concat(new object[]
			{
				"Update [HL_UserInfo] Set ",
				fields_infr,
				" Where UserID=",
				userid
			});
			if (myparam != null && fields != string.Empty)
			{
				flag = true;
			}
			if (myparam_infr != null && fields_infr != string.Empty)
			{
				flag2 = true;
			}
			if (flag || flag2)
			{
				this.conn.BeginTransaction();
				try
				{
					if (flag)
					{
						this.conn.ExecuteTransaction(commandText, myparam);
					}
					if (flag2)
					{
						if ((int)this.conn.ExecuteTransactionScalar("Select count(UserID) From [HL_UserInfo] Where UserID=" + userid) == 0)
						{
							this.conn.ExecuteTransaction("Insert Into [HL_UserInfo]([UserID]) values(" + userid + ")");
						}
						this.conn.ExecuteTransaction(commandText2, myparam_infr);
					}
				}
				catch (Exception ex)
				{
					this.conn.Rollback();
					throw ex;
				}
				this.conn.Commit();
			}
			return true;
		}
		public bool UpdateUser(int UserID, string Password, string Email, string Question, string Answer, int Sex, int GroupID, int UserEP, int IsLocked, decimal Balance)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@Password", DbType.String, Password),
				this.conn.CreateParameter("@Email", DbType.String, Email),
				this.conn.CreateParameter("@Question", DbType.String, Question),
				this.conn.CreateParameter("@Answer", DbType.String, Answer),
				this.conn.CreateParameter("@Sex", DbType.Int32, Sex),
				this.conn.CreateParameter("@GroupID", DbType.Int32, GroupID),
				this.conn.CreateParameter("@UserEP", DbType.Int32, UserEP),
				this.conn.CreateParameter("@IsLocked", DbType.Int32, IsLocked),
				this.conn.CreateParameter("@Balance", DbType.Decimal, Balance),
				this.conn.CreateParameter("@UserID", DbType.String, UserID)
			};
			int num = this.conn.Execute("UPDATE [HL_User] Set [Password]=@Password, [Email]=@Email, [Question]=@Question, [Answer]=@Answer, [Sex]=@Sex, [GroupID]=@GroupID, [UserEP]=@UserEP,  [IsLocked]=@IsLocked, [Balance]=@Balance Where ([UserID] = @UserID)", parameters);
			return num == 1;
		}
		public DataTable GetUserByGroupID(int GroupID)
		{
			return this.conn.GetDataTable("SELECT UserName,UserID,Email From [HL_User] Where GroupID=" + GroupID);
		}
		public DataTable GetUserByGroupID(string GroupID)
		{
			DataTable result;
			if (GroupID.Contains(","))
			{
				result = this.conn.GetDataTable("SELECT UserName,UserID,Email From [HL_User] Where GroupID in(" + GroupID + ")");
			}
			else
			{
				result = this.GetUserByGroupID(int.Parse(GroupID));
			}
			return result;
		}
		public DataTable GetUserByEmail(string Email)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@Email", DbType.String, Email);
			return this.conn.GetDataTable("SELECT * From [HL_User] Where ([Email] = @Email)", new IDbDataParameter[]
			{
				dbDataParameter
			});
		}
		public bool ActiveAccount(string UserName, string CheckNum, string Type)
		{
			bool result;
			if (CheckNum == string.Empty)
			{
				result = false;
			}
			else
			{
				string commandText;
				if (Type == "ActiveAccount")
				{
					commandText = "Update [HL_User] Set CheckNum='',IsLocked=0 Where UserName=@UserName and CheckNum=@CheckNum";
				}
				else
				{
					if (Type == "ConfirmEmail")
					{
						commandText = "Update [HL_User] Set CheckNum='',BindEmail=1 Where UserName=@UserName";
					}
					else
					{
						commandText = "Update [HL_User] Set CheckNum='' Where UserName=@UserName and CheckNum=@CheckNum";
					}
				}
				IDbDataParameter[] parameters = new IDbDataParameter[]
				{
					this.conn.CreateParameter("@UserName", DbType.String, UserName),
					this.conn.CreateParameter("@CheckNum", DbType.String, CheckNum)
				};
				int num = this.conn.Execute(commandText, parameters);
				result = (num == 1);
			}
			return result;
		}
		public int UpdateUserCard(string CardNum, string CardPass, int UserID, string UserName)
		{
			CardBll cardBll = new CardBll(this.conn);
			DataTable cardByNumPass = cardBll.GetCardByNumPass(CardNum, CardPass);
			int result;
			if (cardByNumPass.Rows.Count == 0)
			{
				result = 9;
			}
			else
			{
				decimal num = decimal.Parse(cardByNumPass.Rows[0]["CardMoney"].ToString());
				string text = cardByNumPass.Rows[0]["CardState"].ToString();
				int num2 = Convert.ToInt32(cardByNumPass.Rows[0]["CardID"]);
				if (text.Trim() == "1")
				{
					result = 1;
				}
				else
				{
					if (text.Trim() == "3")
					{
						result = 3;
					}
					else
					{
						decimal d = (decimal)this.conn.GetScalar("Select Balance From [HL_User] Where UserID=" + UserID, new IDbDataParameter[0]);
						decimal num3 = d + num;
						if (num3 <= 0m)
						{
							result = 7;
						}
						else
						{
							string userBalanceKey = Text.GetUserBalanceKey(UserID, num3);
							this.conn.BeginTransaction();
							try
							{
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"Update [HL_Card] Set CardState=1,CardUserName='",
									UserName,
									"',CardUseTime='",
									DateTime.Now.ToString(),
									"' Where CardID=",
									num2
								}));
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"Insert Into [HL_AccountDetails](UserID, cMoney, uBalance, cType, CreateTime, Remark) values(",
									UserID,
									",",
									num,
									",",
									num3,
									", 1,'",
									DateTime.Now.ToString(),
									"', '充值卡充值')"
								}));
								this.conn.ExecuteTransaction(string.Concat(new object[]
								{
									"Update [HL_User] Set Balance=",
									num3,
									", EncryptMoney='",
									userBalanceKey,
									"' Where UserID=",
									UserID
								}));
							}
							catch
							{
								this.conn.Rollback();
								result = 8;
								return result;
							}
							this.conn.Commit();
							result = 0;
						}
					}
				}
			}
			return result;
		}
		public bool AccountVoucher(int UserID, decimal Money, string Remark)
		{
			bool result;
			if (Money <= 0m || UserID <= 0)
			{
				result = false;
			}
			else
			{
				decimal d = (decimal)this.conn.GetScalar("Select Balance From [HL_User] Where UserID=" + UserID, new IDbDataParameter[0]);
				IDbDataParameter dbDataParameter = this.conn.CreateParameter("@Remark", DbType.String, Remark);
				string userBalanceKey = Text.GetUserBalanceKey(UserID, d + Money);
				this.conn.BeginTransaction();
				try
				{
					this.conn.ExecuteTransaction(string.Concat(new object[]
					{
						"Update HL_User Set Balance=",
						d + Money,
						",EncryptMoney='",
						userBalanceKey,
						"' Where UserID=",
						UserID
					}));
					this.conn.ExecuteTransaction(string.Concat(new object[]
					{
						"Insert Into [HL_AccountDetails](UserID, cMoney, uBalance, cType, CreateTime, Remark) values(",
						UserID,
						",",
						Money,
						",",
						d + Money,
						", 1,'",
						DateTime.Now.ToString(),
						"', @Remark)"
					}), new IDbDataParameter[]
					{
						dbDataParameter
					});
				}
				catch
				{
					this.conn.Rollback();
					result = false;
					return result;
				}
				this.conn.Commit();
				result = true;
			}
			return result;
		}
		public bool IsChangedMoney(int UserID)
		{
			DataTable dataTable = this.conn.GetDataTable("Select Balance, EncryptMoney From [HL_User] Where UserID=" + UserID);
			bool result;
			if (dataTable.Rows.Count <= 0)
			{
				result = false;
			}
			else
			{
				string a = dataTable.Rows[0]["EncryptMoney"].ToString();
				decimal balance = (decimal)dataTable.Rows[0]["Balance"];
				result = !(a == Text.GetUserBalanceKey(UserID, balance));
			}
			return result;
		}
		public bool updateEmail(int userID, string Email)
		{
			IDbDataParameter dbDataParameter = this.conn.CreateParameter("@Email", DbType.String, Email);
			string commandText = "update HL_User set [Email] = @Email where UserID = " + userID;
			return this.conn.Execute(commandText, new IDbDataParameter[]
			{
				dbDataParameter
			}) > 0;
		}
		public void UpdateAccountDetails(int UserID, decimal Balance)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@UserID", DbType.String, UserID),
				this.conn.CreateParameter("@Balance", DbType.Decimal, Balance)
			};
			this.conn.Execute("update [HL_AccountDetails] set [uBalance]=@Balance where [UserID]=@UserID and [ID]=(select top(1) ID from HL_AccountDetails where UserID=@UserID order by ID desc)", parameters);
		}
	}
}
